﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DatabaseCore;
using System.Collections.Generic;
using System.Linq;

namespace Export.UnitTest
{
    [TestClass]
    public class Order
    {
        [TestMethod]
        public void TestChageOrderStatus()
        {
           var orderDao = new OrderDao();
            int expectStatus = 5;
            using (var ctx = new ExportDBEntities())
            {
                var orders = (from o in ctx.tbl_Order select o);
                if (orders != null && orders.Count() > 0)
                {
                    tbl_Order newOrder = orders.FirstOrDefault();
                    newOrder.Status = expectStatus;
                    orderDao.Update(newOrder);
                    IList<tbl_Order> updatedOrder = orderDao.Search(newOrder.OrderNo);
                    Assert.AreEqual(expectStatus, updatedOrder[0].Status, "incorrect update order status");
                }
            }

        }
    }
}
